<template>
  <div>
    <el-form class="title">目前正在增加管理员</el-form>
    <el-form
      :model="AdmCart"
      label-width="100px"
      class="demo-AdmCart"
      ref="AdmCart"
      style="width: 60%;line-height=''"
    >
      <el-form-item label="管理员名字：" prop="name">
        <el-input v-model="AdmCart.username" style="width: 90%"></el-input>
      </el-form-item>
      <el-form-item label="管理员密码：" prop="price">
        <el-input v-model="AdmCart.password" style="width: 90%"></el-input>
      </el-form-item>
      <el-form-item label="管理员权限：" prop="price">
        <el-input v-model="AdmCart.part" style="width: 90%"></el-input>
      </el-form-item>
      <el-form-item>
        <el-button @click.prevent="addAdms(AdmCart)" type="primary">立即创建</el-button>
        <el-button @click="resetForm('AdmCart')">重置</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
import axios from "axios";
import { createNamespacedHelpers } from "vuex";
const { mapState: mapState, mapActions: mapActions } = createNamespacedHelpers(
  "admstores"
);
export default {
  data() {
    return {
      AdmCart: {
        username: "",
        password: "",
        part: "",
      },
      allAdm: [],
     
    };
  },
  created() {
    this.getadmAsync();
  },
  methods: {
    async getadmAsync() {
      const { data } = await axios.get("/adm/getAdm");
      console.log(data);
      this.allAdm = data;
    },
    async addAdms(adm) {
      console.log(adm);
      const { data } = await axios.post("adm/addAdm", adm);
      // context.dispatch("getStudentsAsync", data);
      if (data) {
        this.$message({
          type: "success",
          message: "新增成功！"
        });
        this.AdmCart = {};
      }
    },

    resetForm() {
      this.AdmCart = {};
    },
    // ...mapActions(["addGoods"])
  },

};
</script>

<style>
.avatar-uploader {
  width: 50px;
  height: 50px;
}
.el-upload--picture-card {
  width: 100px;
  height: 100px;
  line-height: 100px;
}
.el-upload-list__item{
  width: 100px !important;
  height: 100px !important;
  line-height: 100px;
}
.el-icon-upload-success{
  position:absolute;
  right: 15px !important;
  top: -1px !important;
}
.el-breadcrumb {
  padding-left: 25px;
  height: 30px;
}
.el-form-item:nth-child(1),.el-form-item:nth-child(2),.el-form-item:nth-child(3){
  height: 30px;
}
.el-form-item:last-child{
  height: 20px;
}
.demo-AdmCart{
  
  margin: 0 auto;
}
.title{
  font-size: 20px;
  font-weight: 500;
}
</style>